<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-06-28 18:24
 * Modified Time: 2019-06-28 18:24
 * Version: 2.0
 */

namespace App\Models;


use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

class OrderComment extends Model
{
	protected $table="order_comment";
	protected $guarded =[];

	public function resource(){
		return $this->hasMany(CommentResource::class, 'comment_id', 'id');
	}

	public function orderCommentLike(){
		return $this->hasMany(OrderCommentLike::class,'comment_id','id');
	}

	public function scopeCommentLikeByMemberId(Builder $query,$memberId){
		return $query->has('orderCommentLike','and',function($q) use($memberId){
				$q->where('member_id',$memberId);
			}
			);
	}


	public function order(){
		return $this->hasOne(Order::class,'id','order_id');
	}

	public function reply(){
		return $this->hasOne(OrderCommentReply::class,'comment_id','id');
	}

	public function member(){
		return $this->hasOne(Member::class,'id','member_id');
	}

	public function user(){
		return $this->hasOne(User::class, 'id','user_id');
	}



}